package com.bruce.practice.if_refactor;

/**
 * @author luotuan
 * @create 2019-01-09 14:09
 **/
public class Calculator {
    public static void main(String[] args) {
        int result = calculateUsingFactory(10,4,"divide");
        System.out.println("Result-->"+result);
    }
    public static int calculateUsingFactory(int a,int b,String operation){
        Operation targetOpeation = OperatorFactory.getOperation(operation).orElseThrow(()->new IllegalArgumentException("Invalid operator"));
        return targetOpeation.apply(a,b);
    }
}
